package com.itita.ww2.model.user.battle;

import com.itita.ww2.game.worldmap.event.WorldMapEventDispatch;
import com.itita.ww2.model.user.UserProfile;
import com.itita.ww2.model.worldmap.Base;
import com.smartfoxserver.v2.entities.data.ISFSObject;

public class WorldBattleState extends BaseBattleState {
	// private static final Logger logger = LoggerFactory.getLogger(WorldBattleState.class);
	// 
	private Base base;

	public WorldBattleState(UserProfile userProfile, ISFSObject lastDeployArmy, Base base) {
		super(userProfile);
		setLastDeployArmy(lastDeployArmy);
		this.base = base;
		this.battleType = BattleType.WorldBattle;
		this.offlineSubArmy = false;
	}

	@Override
	public void startBattle() {
		super.startBattle();
	}

	@Override
	public void endBattle(boolean online, boolean victory) {
		super.endBattle(online, victory);
		// 玩家离线
		if (!online) {
			// 重设被攻击据点状态
			base.resetUnderAtk();
			// 触发事件
			WorldMapEventDispatch.onBaseDataUpdate(base);
		}
	}

	public Base getBase() {
		return base;
	}
}
